package D12_6z.反射_2;

import java.lang.reflect.Method;

public class Demo {
    public static void main(String[] args) throws Exception {
        Class<?> aClass = Class.forName("Y2019.M12_.D12_6z.反射_2.Person");
        Method setName = aClass.getDeclaredMethod("setName", String.class);
        setName.setAccessible(true);
        Object o = aClass.newInstance();
        setName.invoke(o,"王志豪");
        Method getName = aClass.getDeclaredMethod("getName");
        getName.setAccessible(true);
        System.out.println(getName.invoke(o,null));
    }
}
